import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import BaseEntity from "./base";
import { User } from "./user";
import { Attachment } from "./attachment";
import { Post } from "./post";

@Entity("comments")
export class Comment extends BaseEntity {
  @Column()
  content: string;

  @OneToMany(() => Attachment, (attachment) => attachment.post)
  attachments: Attachment[];

  @ManyToOne(() => Post, (post) => post.comments)
  @JoinColumn()
  post: Post;

  @ManyToOne(() => User, (user) => user.comments)
  @JoinColumn()
  user: User;
}
